package br.unirio.parser;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
public class ParseArtista{
	
	
	public static void main(String[] args) throws Exception {
			
			BufferedReader reader = new BufferedReader(new FileReader("src/br/unirio/parser/artistas.txt"));
			BufferedWriter writer = new BufferedWriter(new FileWriter("src/br/unirio/parser/script-artistas.txt"));
			BufferedWriter writer2 = new BufferedWriter(new FileWriter("src/br/unirio/parser/script-estilosartistas.txt"));
			String linha = reader.readLine();
			String[] parametros = null;
			
			while(linha != null)
			{
				parametros = linha.split("#");
				writer.append("insert into Artista(id,nome) values ("+parametros[0]+", \""+parametros[1]+"\"); \n");
				for(int i=2; i < parametros.length; i++){
					writer2.append("insert into EstiloArtista(IDEstilo, IDArtista) values (" +
							" (select ID from Estilo where Nome = \""+parametros[i]+"\"),"+parametros[0]+" );  \n");
				}
				linha = reader.readLine();
			}
			writer.flush();
			writer2.flush();
	}
}